<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .parent {
            width: 200px;
            height: 200px;
            background: red;
        }

        .child {
            width: 100px;
            height: 100px;
            background: yellow;
            margin: 50px;
        }
    </style>
</head>

<body>
    <div class="parent" id="parent">
        <div class="child" id="child">

        </div>
    </div>

    <script>
        /* 事件捕获：从不太具体的节点 最早接受事件，而具体的节点最后接受事件 */
        /* 绑定事件：1.onclick  --直接绑定的方式 只会触发1次*/
        // addEventListener(event,function,boolean)
        /* true-->事件捕获 */
        /* false-->事件冒泡 
        默认时false*/
        var parent = document.getElementById("parent");
        var child = document.getElementById("child");
      /*   child.onclick=function(){
            console.log(1);
        }
        child.onclick=function(){
            console.log(2);
        } */
        child.addEventListener('click',function(){
            console.log(1);
        })
        child.addEventListener('click',function(){
            console.log(2);
        })
    </script>

</body>

</html>